//
//  Login.m
//  CarDeal_IOS
//
//  Created by 孙可 on 2018/8/20.
//  Copyright © 2018年 sunke. All rights reserved.
//

#import "Login.h"

@implementation Login

+(BOOL)isLogin{
    if([self getUserInfo] == nil){
        return NO;
    }else{
        return YES;
    }
};


+(void)saveUserInfo:(User *)user{
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:user];
    NSUserDefaults * nd = [NSUserDefaults standardUserDefaults];
    [nd setObject:data forKey:@"userInfo"];
};

+(User *)getUserInfo{
    NSUserDefaults *nsd = [NSUserDefaults standardUserDefaults];
    
    NSData *data = [nsd objectForKey:@"userInfo"];
    
    User * user = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    
    [nsd synchronize];
    
    return user;
}

+(void)clearUserInfo{
    NSUserDefaults *nsd = [NSUserDefaults standardUserDefaults];

    [nsd removeObjectForKey:@"userInfo"];
    
    [nsd synchronize];
}


@end
